import { request1,request2, request7, request8 } from './request'

export function getUser(user_id) {
  return request7({
    params: {
      user_id
    },
  })
}

export function getAvatar(user_id, file) {
  return request8({
    url: `/${user_id}/avatar`,
    method: 'post',
    processData: false,
    data: file
  })
}

export function getNearby(keyword) {
  return request1({
    url: '/pois',
    params: {
      type: 'nearby',
      keyword
    }
  })
}

export function getAddressesInfo(user_id, data) {

  data.poi_type = data.poi_type ? data.poi_type : 0
  data.sex = data.sex ? data.sex : 1
  data.tag = data.tag ? data.tag : '公司'
  data.tag_type = data.tog_type ? data.tog_type : 4
  return request1({
    url: `/users/${user_id}/addresses`,
    method: 'post',
    data
  })
}

export function getAddresses(user_id) {
  return request1({
    url: `/users/${user_id}/addresses`
  })
}

export function deleteAddresses(user_id,adress_id) {
  return request1({
    url: `/users/${user_id}/addresses/${adress_id}`,
    method: 'delete'
  })
}

export function getSignOut() {
  return request2({
    url: '/signout'
  })
}